<style>
.order-statusins {
  width: 860px;
  margin: 0 auto 0 auto;
  overflow: hidden;
}
.order-statusins li {
  float: left;
  width: 172px;
  text-align: center;
}
.consigneeinfo,
.order-payment {
  margin: 20px 0;
}
.consigneeinfo {
  font-size: 16px;
  line-height: 20px;
  margin: 20px auto 40px auto;
}
.order-goods {
  margin-bottom: 20px;
  text-align: center;
}
.order-goods th {
  border-bottom: 1px solid #e3e3e3;
  padding: 4px 10px;
  background-color: #f8f8f8;
  font-size: 16px;
  font-weight: normal;
  vertical-align: middle;
}
.order-goods td {
  border-bottom: 1px solid #e3e3e3;
  padding: 10px;
  vertical-align: middle;
}
.order-goods .describe {
  font-weight: normal;
  line-height: 20px;
}
</style>
<div class="partner-title">
  <strong class="pull-left"><?php echo L('order_sn');?>: <?php echo $orderInfo['order_sn']; ?></strong>
  <?php if ($orderInfo['payment_status'] == OrderModel::PAY_UNPAYED && in_array($orderInfo['order_status'], array(OrderModel::ORDER_UNCONFIRMED ,OrderModel::ORDER_CONFIRMED))): ?>
  <a href="<?php echo url('order/order_edit','oid='.$orderInfo['id']);?>" class="btn pull-right"><?php echo L('editorderinfo');?></a>
  <?php elseif($orderInfo['order_status']==OrderModel::ORDER_CONFIRMED && in_array($orderInfo['shipping_status'], array(OrderModel::SHIPPING_SHIPPED ,OrderModel::SHIPPING_SHIPPED_PART))):?>
  <a href="<?php echo url('order/order_edit_status', array('oid' => $orderInfo['id'], 'status' => OrderModel::ORDER_COMPLETE));?>" class="btn pull-right"><?php echo L('confrim_order');?></a>
  <?php endif;?>

  <?php if($orderInfo['car_type'] && $orderInfo['payment_status'] == OrderModel::PAY_PAYED && $orderInfo['order_status'] !=2):?>
    <?php if($orderInfo['pay_return']){?>
      <?php echo $orderInfo['return_status'];?>
      <?php }else{?>
        <?php if($orderInfo['productList'][0]['refund']){?>
        <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>)" class="btn pull-right"><?php echo L('application_for_drawback');?></a>
        <?php }else{?>
        <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>, <?php echo L('if_he_will_notbe_deposit');?>【<?php echo currency($orderInfo['productList'][0]['yufu_price']);?>】<?php echo L('return');?>')" class="btn pull-right"><?php echo L('application_for_drawback');?></a>
      <?php }?>
    <?php }?>
  <?php endif;?>
</div>
<!-- 订单状态 -->
<div class="order-status">
  <?php
    $step = 0;
    if($orderInfo['start_time']){
      if($orderInfo['payment_time']){
      	$step = 1;
      	$orderInfo['shipping_action_time'] = M('orders_log')->where(array('order_id'=>$orderInfo['id'],'shipping_status'=>99))->getField('action_time');
      	if($orderInfo['shipping_time']){
      		if($orderInfo['end_time']){
      			$step = 4;
      		}else{
      			$step = 3;
      		}
      	}else{
      		if($orderInfo['shipping_action_time']) $step = 2;
      	}
      }
    }
  ?>
  <ul class="clearfix status-diagram">
    <li class="current">
      <i class="circle"></i>
      <span class="bar"></span>
      <i class="triangle-right"></i>
    </li>
    <li<?php if($step >= 1):?> class="current"<?php endif;?>>
      <i class="circle"></i>
      <span class="bar"></span>
      <i class="triangle-right"></i>
    </li>
    <li<?php if($step >= 2):?> class="current"<?php endif;?>>
      <i class="circle"></i>
      <span class="bar"></span>
      <i class="triangle-right"></i>
    </li>
    <li<?php if($step >= 3):?> class="current"<?php endif;?>>
      <i class="circle"></i>
      <span class="bar"></span>
      <i class="triangle-right"></i>
    </li>
    <li class="last<?php if($step >= 4):?> current<?php endif;?>">
      <i class="circle"></i>
    </li>
  </ul>
  <ul class="clearfix">
    <?php if($orderInfo['order_status'] == OrderModel::ORDER_CANCELED): ?>
    <li>
      <div><?php echo L('_cancelled_');?></div>
      <div><?php echo date('Y-m-d',$orderInfo['update_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['update_time']);?></div>
    </li>
    <?php else: ?>
    <li>
      <div><?php echo L('completed_order');?></div>
      <div><?php echo date('Y-m-d',$orderInfo['start_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['start_time']);?></div>
    </li>
    <?php endif; ?>
    <li>
      <div><?php echo L('_PAY_PAYED_');?></div>
      <?php if($orderInfo['payment_time']):?>
      <div><?php echo date('Y-m-d',$orderInfo['payment_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['payment_time']);?></div>
      <?php endif;?>
    </li>
    <li>
      <div><?php echo L('making');?></div>
      <?php if($orderInfo['shipping_action_time']):?>
      <div><?php echo date('Y-m-d',$orderInfo['shipping_action_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['shipping_action_time']);?></div>
      <?php endif;?>
    </li>
    <li>
      <div><?php echo L('_SHIPPING_SHIPPED_');?></div>
      <?php if($orderInfo['shipping_time']):?>
      <div><?php echo date('Y-m-d',$orderInfo['shipping_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['shipping_time']);?></div>
      <?php endif;?>
    </li>
    <li class="last">
      <div><?php echo L('_ACCOUNT_COMPLETED_');?></div>
      <?php if($orderInfo['end_time']):?>
      <div><?php echo date('Y-m-d',$orderInfo['end_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['end_time']);?></div>
      <?php endif;?>
    </li>
  </ul>
</div>
<!-- 收货人信息 -->
<div class="partner-title"><?php echo L('consignee');?></div>
<div class="consigneeinfo">
<div><?php echo isset($orderInfo['delivery_first_name']) ? $orderInfo['delivery_first_name'] : ''; ?>,<?php echo isset($orderInfo['delivery_last_name']) ? $orderInfo['delivery_last_name'] : ''; ?>/<?php echo isset($orderInfo['delivery_address']) ? $orderInfo['delivery_address'] : ''; ?>,<?php echo isset($orderInfo['delivery_city']) ? $orderInfo['delivery_city'] : ''; ?>,<?php echo isset($orderInfo['delivery_province']) ? $orderInfo['delivery_province'] : ''; ?>,<?php echo isset($orderInfo['delivery_country']) ? $orderInfo['delivery_country'] : ''; ?>/<?php echo isset($orderInfo['delivery_phone']) ? $orderInfo['delivery_phone'] : ''; ?></div>
<div><?php echo isset($orderInfo['delivery_email']) ? $orderInfo['delivery_email'] : ''; ?>/<?php echo isset($orderInfo['delivery_postcode']) ? $orderInfo['delivery_postcode'] : ''; ?></div>
</div>
<?php if($orderInfo['measure_data'] ):?>

<div class="partner-title">体型数据</div>
<div class="item-title">尺寸</div>
<table class="Garment_size">
  <tbody>
  <?php 	$data = unserialize($orderInfo['measure_data']['measure_data']);
  $i==0;
  foreach ($data as $key => $val){
    switch($key){
      case "stomach";
        $key="stomack_size";
        break;
      case "thigh";
        $key="thigh_size";
        break;
      case "shoulder";
        $key="shoulder_size";
        break;
      case "wrist";
        $key="wrist_size";
        break;
      case "knee";
        $key="knee_size";
        break;
      case "bicep";
        $key="bicep_size";
        break;
      case "sleeve";
        $key="sleeve_length";
        break;
      case "neck";
        $key="neck_length";
        break;
      case "neck";
        $key="shirt_length";
        break;
      case "shirt";
        $key="shirt_length";
        break;
      default:
    }
  ?>
  <?php if($i%3==0){ ?>
  <tr>
    <?php } ?>
    <td>
      <?php if($key=="shoulder_size"){ ?>
          <?php  echo L('shoulders');?>:<?php if($val['type']==1) echo L('square_shoulders'); else if($val['type']==2) echo L('rounder_shoulders'); else if($val['type']==3) echo L('sloping_shoulders'); ?>
      <?php }else if($key=="posture"){ ?>
          <?php  echo L($key);?>:<?php if($val['type'] == 1): echo L('flat_posture');elseif($val['type'] == 3): echo L('straight_posture');elseif($val['type'] == 5): echo L('relaxed_posture');endif;?>
      <?php }else if($key=="chest"){ ?>
        <?php  echo L($key);?>:<span class="space"><?php echo $val['cm']; ?></span><em>cm</em>/<?php if($val['type'] == 1): echo  L('muscular_chest');elseif($val['type'] == 3): echo L('flat_chest');elseif($val['chest_type']['type'] == 5): echo L('large_chest');endif;?>
      <?php }else if($key=="stomack_size"){ ?>
        <?php  echo L($key);?>:<span class="space"><?php echo $val['cm']; ?></span><em>cm</em>/<?php if($val['type'] == 1): echo L('flat_stomach ');elseif($val['type'] == 3): echo L('slightly_rounded_stomach');elseif($val['type'] == 5): echo L('rounded_stomach');endif;?>
      <?php }else if($key=="weight"){ ?>
        <?php  echo L($key);?>:<span class="space"><?php echo $val['kg']; ?></span><em>kg</em>
      <?php }else if($key=="age"){ ?>
        <?php  echo L($key);?>:<span class="space"><?php echo $val['age']; ?></span>
      <?php }else{ ?>
          <?php  echo L($key);?>:<span class="space"><?php echo $val['cm']; ?></span><em>cm</em>
      <?php } ?>
    </td>
    <?php if($i%3==2){ ?>
  </tr>
  <?php } ?>
    <?php $i++; ?>
  <?php } ?>
  </tbody>
</table>
<?php endif; ?>

<!-- 备注 -->
<div class="partner-title"><?php echo L('remark');?></div>
<div class="consigneeinfo">
<div><?php echo isset($orderInfo['remark']) ? $orderInfo['remark'] : ''; ?></div>
</div>
<!-- 配送支付方式 -->
<div class="partner-title"><?php echo L('shipping_method');?></div>
<div class="clearfix order-payment">
  <p class="pull-left">
    <?php echo L('shippingmethod');?>:
    <strong><?php echo isset($orderInfo['shipping_method_name']) ? $orderInfo['shipping_method_name'] : null ?>
    (<?php echo $orderInfo['shipping_method'];?><?php echo !empty($orderInfo['shipping_no']) ? ':'.$orderInfo['shipping_no'] : '';?>)
    </strong>
  </p>

  <?php if($orderInfo['car_type'] && $orderInfo['payment_status'] == OrderModel::PAY_PAYED && $orderInfo['order_status'] !=2):?>
    <?php if($orderInfo['pay_return']){?>
      <?php echo $orderInfo['return_status'];?>
      <?php }else{?>
        <?php if($orderInfo['productList'][0]['refund']){?>
        <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>)" class="pull-right"><?php echo L('user_changer_order_details')?></a>
        <?php }else{?>
        <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>, <?php echo L('if_he_will_notbe_deposit');?>【<?php echo currency($orderInfo['productList'][0]['yufu_price']);?>】<?php echo L('return');?>')" class="pull-right"><?php echo L('user_changer_order_details')?></a>
        <?php }?>
    <?php }?>
  <?php endif;?>
</div>
<form action="/partner/update_order/oid/<?php echo $_GET['oid']?>" method="post">
<!--支付方式-->
<div class="partner-title"><?php echo L('payment_method')?></div>
<?php if($orderInfo['payment_status'] != OrderModel::PAY_PAYED):?>
<dl class="clearfix order-payment js-payment-method">
  <dt class="caption hide"><input type="hidden" name="payment_method" value="<?php echo $orderInfo['payment_method'];?>" /><i>3</i><?php echo L('payment_method')?></dt>
  <?php
    if(isset($paymentList) && $paymentList):
      $i=1;
      foreach ($paymentList as $k => $payment) :
        if (!$payment['status']) continue;
  ?>
  <dd class="col-md-6 col-sm-6<?php if ($payment['name'] == $orderInfo['payment_method']){?> selected<?php } ?>" data-info="<?php echo $payment['name'];?>">
    <div class="inner">
      <p class="text"><?php if($payment['name'] =="Visabill"){echo L('_credit_');}elseif($payment['name'] == "Paypal"){echo L('_paypal_');}elseif($payment['name'] == "Worldpay"){echo L('_worldpay_');};?></p>
      <img src="/statics/front/images/cart/<?php if($payment['name'] =="Visabill"){echo "visa";}elseif($payment['name'] == "Paypal"){echo "paypal";}elseif($payment['name'] == "Worldpay"){echo "worldpay";};?>.png" alt="<?php echo isset($payment['name']) ? $payment['name'] : null ;?>" />
      <i class="mark"></i>
    </div>
  </dd>
  <?php
        $i++;
      endforeach;
    endif;
  ?>
</dl>
<?php else:?>
<div class="consigneeinfo">
  <?php echo L('payment_method');?>:
  <strong>
  <?php if($orderInfo['payment_status'] == OrderModel::PAY_PAYED && $orderInfo['pay_amount'] == 0){
    echo L('use_balance_to_pay');
  }else{
    echo isset($orderInfo['payment_method_name']) ? $orderInfo['payment_method_name'] : null;
  }?>
  </strong>
</div>
<?php endif;?>
<!--订单商品-->
<table class="order-goods">
  <tr>
    <th width="10%"><?php echo L('product_image')?></th>
    <th width="20%"><?php echo L('order_goods');?></th>
    <th width="10%"><?php echo L('goods_price');?></th>
    <th width="10%"><?php echo L('goods_number');?></th>
    <th width="10%"><?php echo L('amount_about');?></th>
    <th width="20%"><?php echo L('figure_data');?></th>
    <th width="20%">下单备注</th>
  </tr>
  <?php
    if (isset($orderInfo['productList'])):
      foreach ($orderInfo['productList'] as $k => $product):
  ?>
  <tr>
    <td><img src="<?php echo $product['small_img'] ?>" alt="goods image" width="50" height="50" /></td>
    <td>
      <a class="link-gray" href="<?php echo url('product/'.$product['product_id'].'-'.generateUrl_un($product['product_name']));?>"><?php echo $product['product_name'] ?></a>
      <br/>
      <a class="cur-pointer check-options js-check-options"><?php echo L('_change_the_customization_options_');?></a>
      <?php if($product['custom_type']==2):?>
      <?php
        $size_type = $product['size_type'];
        $attributeList = $product['attributeList'];
      ?>
      <div class="hide align-left pt2x pb2x custom-list js-custom-list"><?php include THEMES_PATH . 'public/check_options.phtml'; ?></div>
      <?php endif; ?>
    </td>
    <td><?php echo currency(($product['total_amount']-$product['pants_price']*$product['pants_qty'])/$product['qty']);?></td>
    <td><?php echo $product['qty'] ?></td>
    <td><?php echo currency($product['total_amount']-$product['pants_price']*$product['pants_qty']);?></td>
    <td>
      <?php if($product['model_id'] == 25):?>
      <strong class="text-bold">
        <?php
          $attr_id = 161;
          $attr = $attributeList[$attr_id];
        ?>
        <?php foreach ($attr['values'] as $attrv):?>
        <?php if($attr['default'] == $attrv['product_attr_id']):?>
        <?php echo $attrv['label'];?>:
        <?php endif;?>
        <?php endforeach;?>
        <?php
          $attr_id = 162;
          $attr = $attributeList[$attr_id];
        ?>
        <?php if(isset($attr['default']) && $attr['default']){echo $attr['default'];}?>
      </strong>
      <?php endif;?>
      <?php if($product['measure_id']):?>
        <?php
        $measureInfo = AttributeModel::get_user_measure_info($product['measure_id']);
          if($measureInfo['m_status'] == 5):
        ?>
          <p>
          <?php foreach(unserialize($measureInfo['measure_data']) as $mskey=>$msval):?>
          <?php echo MeasureModel::msizedataShow($mskey);?>:<strong class="text-bold"><?php echo $msval;?></strong><br />
          <?php endforeach;?>
          </p>
        <?php else:?>
          <?php echo $measureInfo['measure_name'];?>
        <?php endif;?>
      <?php endif;?>
      </td>
      <td><?php echo $product['special_request_1'] ?></td>
    </tr>
    <?php if($product['pants_qty'] > 0):?>
    <tr>
      <td></td>
      <td><?php echo L('AdditionalPants'); ?></td>
      <td><?php echo currency($product['pants_price']);?></td>
      <td><?php echo $product['pants_qty'] ?></td>
      <td><?php echo currency($product['pants_price']*$product['pants_qty']);?></td>
      <td></td>
      <td></td>
    </tr>
    <?php endif;?>
    <?php
        endforeach;
      endif;
    ?>
    <?php if (isset($orderInfo)): ?>
    <tr>
      <td colspan="7" align="right"><?php echo L('all_goods_total');?> : <?php echo isset($orderInfo['product_amount']) ? currency($orderInfo['product_amount']) : ''; ?> + <?php echo L('shipping_fee');?> : <?php echo currency($orderInfo['shipping_fee']);?>  + 附加费用 : <?php echo currency($orderInfo['payment_fee']);?></td>
    </tr>
    <?php if($orderInfo['surplus_money']){?>
    <tr>
      <td colspan="7" align="right">
        - <?php echo L('usebalance');?> : <?php echo currency($orderInfo['surplus_money']);?>
        <input type="hidden" name="surplus_money02" id="input_surplus_money" value="<?php echo $orderInfo['surplus_money'];?>" />
      </td>
    </tr>
    <?php }?>
      <?php if($orderInfo['integral_money']){?>
    <tr>
      <td colspan="7" align="right">- <?php echo L('using_integral_pay');?> : <?php echo currency($orderInfo['integral_money']);?></td>
    </tr>
    <?php }?>
      <?php if($orderInfo['coupon_money']){?>
    <tr>
      <td colspan="7" align="right">- <?php echo L('order_discount_you_save')?> : <?php echo currency($orderInfo['hongbao_money']+$orderInfo['coupon_money']);?></td>
    </tr>
    <?php }?>
    <?php endif ?>
    <tr>
      <td colspan="7" align="right"><?php echo L('paid_amount');?> : <strong id="pay_amount"><?php if (isset($orderInfo['pay_amount'])) echo currency($orderInfo['pay_amount']);?></strong></td>
    </tr>
    <?php if($orderInfo['order_status'] == OrderModel::ORDER_UNCONFIRMED && $orderInfo['payment_status'] == OrderModel::PAY_UNPAYED && $user_money>0):?>
    <tr>
      <td colspan="7" align="right"><?php echo L('balance_amount');?>: <strong id="user_money_1"><?php echo currency($user['user_money'])?></strong></td>
    </tr>
    <tr>
      <td align="right" class="use-balance" colspan="6">
        <label><?php echo L('use_balance_to_pay');?> <input type="checkbox" onclick="get_user_money()" value="1" name="is_user_money" id="is_user_money" /></label>
      </td>
    </tr>

    <?php endif;?>
  </table>
  <div class="align-right"><?php //if($orderInfo['payment_status'] == OrderModel::PAY_UNPAYED) : echo isset($paymentSubmit) ? $paymentSubmit : null; endif;?>
    <?php if($orderInfo['order_status'] == OrderModel::ORDER_UNCONFIRMED && $orderInfo['payment_status'] == OrderModel::PAY_UNPAYED):?>
    <input type="hidden" name="surplus_money" id="surplus_money" value="0" />
    <input type="hidden" name="info_user_money" id="info_user_money" value="<?php echo $user_money;?>" />
    <input type="hidden" name="info_pay_amount" id="info_pay_amount" value="<?php echo $orderInfo['pay_amount'];?>" />
    <input class="pay_button" type="submit" value="<?php echo L('_PAY_NOW_');?>" />
    <?php endif;?>
  </div>
</form>
<script src="/statics/front/js/scripts/cart.js"></script>
<script>
$(function () {
  var use_balance_flag = $('#is_user_money').is(':checked');
  if (use_balance_flag == true) {
    get_user_money();
  }

  //选择支付方式
  $('.js-payment-method').on('click', 'dd', function() {
    var $this = $(this);
    $this.closest('.js-payment-method').find('dt > input[type=hidden]').val($this.data('info'));
    $this.addClass('selected').parent().siblings().find("dd").removeClass('selected');
    getPaymentMoney();
  });

  /*检查定制选项*/
  $('.js-check-options').on('click', function () {//定制项弹出框
    $(this).next('.modal').modal('show');
  });
});

function confirmurl(url, message) {
  if (confirm(message)) {
    redirect(url);
  }
}

function redirect(url) {
  location.href = url;
}

function get_user_money() {
  var use_balance_flag = $('#is_user_money').is(":checked");
  var user_money = parseFloat($('#info_user_money').val());
  var pay_amount = parseFloat($('#info_pay_amount').val());
  var surplus_money = 0;

  if (use_balance_flag == true) {
    if (user_money > 0 && user_money < pay_amount ) {
      pay_amount =  pay_amount - user_money;
      surplus_money = user_money;
      user_money = 0;
    } else if(user_money > 0 && user_money > pay_amount) {
      user_money = user_money - pay_amount;
      surplus_money = pay_amount;
      pay_amount = 0;
    }

    $.ajax({
      url:'/public/paymentc/price/' + pay_amount,
      type:'get',
      error: function() {
        alert('error');
      },
      success: function(data) {
        $('#pay_amount').html(data);
      }
    });
    $.ajax({
      url:'/public/paymentc/price/' + user_money,
      type:'get',
      error: function() {
        alert('error');
      },
      success: function(data) {
        $('#user_money_1').html(data);
      }
    });
  } else {
    $.ajax({
      url:'/public/paymentc/price/' + pay_amount,
      type:'get',
      error:function(){
        alert('error');
      },
      success:function(data){
        $('#pay_amount').html(data);
      }
    });
    $.ajax({
      url:'/public/paymentc/price/' + user_money,
      type:'get',
      error: function () {
        alert('error');
      },
      success: function (data) {
        $('#user_money_1').html(data);
      }
    });
  }
  $('#surplus_money').val(surplus_money);
}
</script>